package xyz.csmcool.imuser.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import xyz.csmcool.imuser.entity.vo.HandleVo;
import xyz.csmcool.imuser.entity.vo.ReplyVo;
import xyz.csmcool.imuser.service.IHandleService;
import xyz.csmcool.imutil.utils.ResultTool;
import xyz.csmcool.imutil.webVo.ResultVo;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author csmcool
 * @since 2022-08-03
 */
@RestController
@RequestMapping("/handle")
@RequiredArgsConstructor
public class HandleController {

    final IHandleService handleService;

    @PostMapping("/add-handle")
    public ResultVo addHandle(@Validated @RequestBody HandleVo handleVo) {
        handleService.addHandle(handleVo);
        return ResultTool.success();
    }

    @PutMapping("/admin/update-handle")
    public ResultVo updateHandle(@Validated @RequestBody ReplyVo handleVo) {
        handleService.reply(handleVo);
        return ResultTool.success();
    }
}
